/*
 * @Author: ischen.x ischen.x@foxmail.com
 * @Date: 2025-07-07 11:14:00
 * @LastEditors: ischen.x ischen.x@foxmail.com
 * @LastEditTime: 2025-07-09 18:01:59
 * 
 * Copyright (c) 2025 by fhchengz, All Rights Reserved. 
 */
#ifndef __DS1302_H
#define __DS1302_H

#include <stdint.h>
#include <time.h>

typedef struct ds1302 {
    uint8_t Seconds;
    uint8_t Minutes;
    uint8_t Hours;
    uint8_t Dates;
    uint8_t Months;
    uint8_t Days;
    uint8_t Years;
    uint8_t Control;
} ds1302_reg_type;

typedef struct {
    void (*sclk_high)(void);
    void (*sclk_low)(void);
    void (*io_high)(void);
    void (*io_low)(void);
    int  (*io_read)(void);
    void (*io_in)(void);
    void (*io_out)(void);
    void (*ce_high)(void);
    void (*ce_low)(void);
    void (*delay_us)(uint32_t us);
} ds1302_gpio_ops_t;

int ds1302_init(void);
int ds1302_get_time(struct tm *time_struct);
int ds1302_set_time(struct tm *time_struct);
int ds1302_set_gpio_ops(const ds1302_gpio_ops_t *ops);

#endif